from flask import Blueprint,request,jsonify
import json
from database import db
# 创建蓝图
bp_users = Blueprint('users',__name__)

#创建蓝图路由
@bp_users.route('/login/',methods=['POST'])
def login():
    data = json.loads(request.data)
    mobile = data['mobile']
    password = data['password']
    sql = "select * from `cuser` where mobile = '%s'" % mobile
    use = db.findone(sql)
    print(use)
    if use:
        if use['password']==password:
            return jsonify({'code':200,'userid':use['id']})
    else:
        return jsonify({'code':10010})